class PWNPlayerController extends UTPlayerController;

var bool NotifiedOfLogin;
var bool PlayerIsMonster;
var int PlayerIsMonsterTickCount;
var bool TimeDilationIsRunning;
var bool TimeDilationHasBeenNoted;
var float TimeDilationDurationSoFar;
var float TimeDilationHasBeenNotedAtTick;
var bool TimeDilationDurationMustStop;
var int ActiveQuest;

simulated event PlayerTick( float DeltaTime )
{
	Super.PlayerTick(DeltaTime);

	// This needs to be done here because it ensures that all datastores have been registered properly
	// it also ensures we do not update the profile settings more than once.
	//if( bRetrieveSettingsFromProfileOnNextTick )
	//{
	//	RetrieveSettingsFromProfile();
	//	bRetrieveSettingsFromProfileOnNextTick = FALSE;
	//}
	if (!TimeDilationHasBeenNoted)
	{
		if (TimeDilationIsRunning)
		{
			TimeDilationHasBeenNoted = true;
			TimeDilationHasBeenNotedAtTick = WorldInfo.TimeSeconds;
		}
	}

	if (TimeDilationHasBeenNoted)
	{
		if ((WorldInfo.TimeSeconds - TimeDilationHasBeenNotedAtTick) > PWNPawn(Pawn).StatsTimeDilationDuration)
		{
			PWNPlayerControllerDebugPrint("Duration of dilation: " $(WorldInfo.TimeSeconds - TimeDilationHasBeenNotedAtTick));
			TimeDilationDurationMustStop = true;
			WorldInfo.TimeDilation = 1;			
			TimeDilationIsRunning = false;
			TimeDilationHasBeenNoted = false;
		}
	}


	if(!NotifiedOfLogin)
	{
		PWNPlayerControllerDebugPrint("PWNPlayerController: PWNPlayerController loaded...");
		NotifiedOfLogin = true;
		PWNPlayerInput(PlayerInput).bInvertMouse = true;
	}
}


//Debug Print Function for ALL CLASSES!
simulated public function PWNPlayerControllerDebugPrint(string sMessage)
{
	GetALocalPlayerController().ClientMessage(sMessage);	
}

function MonsterStateActivate()
{
	PlayerIsMonsterTickCount = 0;
	PlayerIsMonster = true;
}

function MonsterStateDeactivate()
{
	PlayerIsMonsterTickCount = 0;
	PlayerIsMonster = false;
}


state PlayerWalking
{	
	simulated function PlayerMove(float DeltaTime)
	{
		super.PlayerMove(DeltaTime);
		//PWNPlayerControllerDebugPrint("player is in moving state");
		if ((PlayerIsMonster)&&(PlayerIsMonsterTickCount>0)&&(PlayerIsMonsterTickCount%30==0))
		{
			PWNPlayerControllerDebugPrint("Monster!");			
		}
		PlayerIsMonsterTickCount++;
	}

}

function SetActiveQuest()
{
}

defaultproperties
{	
	DefaultFOV=90
	DesiredFOV=90	
	Name="Default__PWNPlayerController"
	InputClass=class'PWNGame.PWNPlayerInput'
	NotifiedOfLogin = false
	PlayerIsMonster = false
	PlayerIsMonsterTickCount = 500
	TimeDilationIsRunning=false
	ActiveQuest = 0
}